//
//  PayWriteScoreTableViewCell.m
//  JxCarios
//
//  Created by xcq on 15/2/5.
//  Copyright (c) 2015年 xiongchuanqi. All rights reserved.
//

#import "PayWriteScoreTableViewCell.h"
#import "payTypeSeleteTableViewCell.h"
#define Point @"1234567890/n"

@implementation PayWriteScoreTableViewCell

- (void)awakeFromNib {
    // Initialization code
    _InputTextfield.delegate = self;
    _InputTextfield.enabled = YES;
    self.selectionStyle = UITableViewCellSelectionStyleNone;
//    [_InputTextfield addTarget:self action:@selector(calculateIntegral:) forControlEvents:UIControlEventValueChanged];
}

- (BOOL)textField:(UITextField *)textField shouldChangeCharactersInRange:(NSRange)range replacementString:(NSString *)string{
     NSString * toBeString = [textField.text stringByReplacingCharactersInRange:range withString:string]; //得到输入框的内容
    NSCharacterSet *cs;
    cs = [[NSCharacterSet characterSetWithCharactersInString:Point]invertedSet];
    NSString *filtered = [[string componentsSeparatedByCharactersInSet:cs]componentsJoinedByString:@""]; //按cs分离出数组,数组按@""分离出字符串
    BOOL canChange = [string isEqualToString:filtered];
    if (canChange) {
        if ([toBeString integerValue] > [_vb integerValue]) {
            return NO;
        }
    }else{
        return NO;
    }
    
    return YES;
}

- (BOOL)textFieldShouldReturn:(UITextField *)textField{
    UIViewController *viewC = (UIViewController *)_target;
    [viewC.view endEditing:YES];
    if (_target) {
        [_target performSelector:_action withObject:textField.text];
    }
    return YES;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

//lldb调试:http://blog.csdn.net/happytengfei/article/details/8060690
- (void)checkCallBack:(UITableViewCell *)cell andSeleted:(BOOL)seleted andDetail:(NSString *)str {
    _InputTextfield.enabled = seleted;
    _InputTextfield.placeholder = str;
}

- (void)calculateIntegral:(UITextField *)sender {
    
}
@end
